home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interfaces / UniversalInterfaces 2.0 / PInterfaces / MIDI.p < prev    next >
Encoding:
Text File  |  1995-04-18  |  11.6 KB  |  380 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        MIDI.p
  3.  
  4.      Contains:    MIDI Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT MIDI;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __MIDI__}
  30. {$SETC __MIDI__ := 1}
  31.  
  32. {$I+}
  33. {$SETC MIDIIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __ERRORS__}
  38. {$I Errors.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __TYPES__}
  43. {$I Types.p}
  44. {$ENDC}
  45.  
  46. {$IFC UNDEFINED __MIXEDMODE__}
  47. {$I MixedMode.p}
  48. {$ENDC}
  49.  
  50. {$PUSH}
  51. {$ALIGN MAC68K}
  52. {$LibExport+}
  53.  
  54. CONST
  55.     midiToolNum                    = 4;                            {tool number of MIDI Manager for SndDispVersion call}
  56.     midiMaxNameLen                = 31;                            {maximum number of characters in port and client names}
  57. { Time formats }
  58.     midiFormatMSec                = 0;                            {milliseconds}
  59.     midiFormatBeats                = 1;                            {beats}
  60.     midiFormat24fpsBit            = 2;                            {24 frames/sec.}
  61.     midiFormat25fpsBit            = 3;                            {25 frames/sec.}
  62.     midiFormat30fpsDBit            = 4;                            {30 frames/sec. drop-frame}
  63.     midiFormat30fpsBit            = 5;                            {30 frames/sec.}
  64.     midiFormat24fpsQF            = 6;                            {24 frames/sec. longInt format }
  65.     midiFormat25fpsQF            = 7;                            {25 frames/sec. longInt format }
  66.     midiFormat30fpsDQF            = 8;                            {30 frames/sec. drop-frame longInt format }
  67.     midiFormat30fpsQF            = 9;                            {30 frames/sec. longInt format }
  68.     midiInternalSync            = 0;                            {internal sync}
  69.     midiExternalSync            = 1;                            {external sync}
  70. { Port types}
  71.     midiPortTypeTime            = 0;                            {time port}
  72.     midiPortTypeInput            = 1;                            {input port}
  73.     midiPortTypeOutput            = 2;                            {output port}
  74.     midiPortTypeTimeInv            = 3;                            {invisible time port}
  75. { OffsetTimes  }
  76.     midiGetEverything            = $7FFFFFFF;                    {get all packets, regardless of time stamps}
  77.     midiGetNothing                = $80000000;                    {get no packets, regardless of time stamps}
  78.     midiGetCurrent                = $00000000;                    {get current packets only}
  79.  
  80. {    MIDI data and messages are passed in MIDIPacket records (see below).
  81.     The first byte of every MIDIPacket contains a set of flags
  82.  
  83.     bits 0-1    00 = new MIDIPacket, not continued
  84.                      01 = begining of continued MIDIPacket
  85.                      10 = end of continued MIDIPacket
  86.                      11 = continuation
  87.     bits 2-3     reserved
  88.  
  89.     bits 4-6      000 = packet contains MIDI data
  90.  
  91.                   001 = packet contains MIDI Manager message
  92.  
  93.     bit 7         0 = MIDIPacket has valid stamp
  94.                   1 = stamp with current clock
  95. }
  96.     midiContMask                = $03;
  97.     midiNoCont                    = $00;
  98.     midiStartCont                = $01;
  99.     midiMidCont                    = $03;
  100.     midiEndCont                    = $02;
  101.     midiTypeMask                = $70;
  102.     midiMsgType                    = $00;
  103.     midiMgrType                    = $10;
  104.     midiTimeStampMask            = $80;
  105.     midiTimeStampCurrent        = $80;
  106.     midiTimeStampValid            = $00;
  107. { MIDIPacket command words (the first word in the data field for midiMgrType messages) }
  108.     midiOverflowErr                = $0001;
  109.     midiSCCErr                    = $0002;
  110.     midiPacketErr                = $0003;
  111. {all command words less than this value are error indicators}
  112.     midiMaxErr                    = $00FF;
  113. { Valid results to be returned by readHooks }
  114.     midiKeepPacket                = 0;
  115.     midiMorePacket                = 1;
  116.     midiNoMorePacket            = 2;
  117. { Driver calls }
  118.     midiOpenDriver                = 1;
  119.     midiCloseDriver                = 2;
  120.  
  121.  
  122. TYPE
  123.     MIDIPacket = PACKED RECORD
  124.         flags:                    UInt8;
  125.         len:                    UInt8;
  126.         tStamp:                    LONGINT;
  127.         data:                    ARRAY [0..248] OF UInt8;
  128.     END;
  129.  
  130.     MIDIPacketPtr = ^MIDIPacket;
  131.  
  132.     MIDIReadHookProcPtr = ProcPtr;  { FUNCTION MIDIReadHook(myPacket: MIDIPacketPtr; myRefCon: LONGINT): INTEGER; }
  133.     MIDITimeProcPtr = ProcPtr;  { PROCEDURE MIDITime(curTime: LONGINT; myRefCon: LONGINT); }
  134.     MIDIReadHookUPP = UniversalProcPtr;
  135.     MIDITimeUPP = UniversalProcPtr;
  136.  
  137.     MIDIClkInfo = RECORD
  138.         syncType:                INTEGER;                                {synchronization external/internal}
  139.         curTime:                LONGINT;                                {current value of port's clock}
  140.         format:                    INTEGER;                                {time code format}
  141.     END;
  142.  
  143.     MIDIIDRec = RECORD
  144.         clientID:                OSType;
  145.         portID:                    OSType;
  146.     END;
  147.  
  148.     MIDIPortInfo = RECORD
  149.         portType:                INTEGER;                                {type of port}
  150.         timeBase:                MIDIIDRec;                                {MIDIIDRec for time base}
  151.         numConnects:            INTEGER;                                {number of connections}
  152.         cList:                    ARRAY [0..0] OF MIDIIDRec;                {ARRAY [1..numConnects] of MIDIIDRec}
  153.     END;
  154.  
  155.     MIDIPortInfoPtr = ^MIDIPortInfo;
  156.     MIDIPortInfoHdl = ^MIDIPortInfoPtr;
  157.     MIDIPortInfoHandle = ^MIDIPortInfoPtr;
  158.  
  159.     MIDIPortParams = RECORD
  160.         portID:                    OSType;                                    {ID of port, unique within client}
  161.         portType:                INTEGER;                                {Type of port - input, output, time, etc.}
  162.         timeBase:                INTEGER;                                {refnum of time base, 0 if none}
  163.         offsetTime:                LONGINT;                                {offset for current time stamps}
  164.         readHook:                MIDIReadHookUPP;                        {routine to call when input data is valid}
  165.         refCon:                    LONGINT;                                {refcon for port (for client use)}
  166.         initClock:                MIDIClkInfo;                            {initial settings for a time base}
  167.         name:                    Str255;                                    {name of the port, This is a real live string, not a ptr.}
  168.     END;
  169.  
  170.     MIDIPortParamsPtr = ^MIDIPortParams;
  171.  
  172.     MIDIIDList = RECORD
  173.         numIDs:                    INTEGER;
  174.         list:                    ARRAY [0..0] OF OSType;
  175.     END;
  176.  
  177.     MIDIIDListPtr = ^MIDIIDList;
  178.     MIDIIDListHdl = ^MIDIIDListPtr;
  179.     MIDIIDListHandle = ^MIDIIDListPtr;
  180.  
  181.  
  182. FUNCTION MIDIVersion: NumVersion;
  183.     {$IFC NOT GENERATINGCFM}
  184.     INLINE $203C, $0000, 4, $A800;
  185.     {$ENDC}
  186. FUNCTION MIDISignIn(clientID: OSType; refCon: LONGINT; icon: Handle; name: ConstStr255Param): OSErr;
  187.     {$IFC NOT GENERATINGCFM}
  188.     INLINE $203C, $0004, 4, $A800;
  189.     {$ENDC}
  190. PROCEDURE MIDISignOut(clientID: OSType);
  191.     {$IFC NOT GENERATINGCFM}
  192.     INLINE $203C, $0008, 4, $A800;
  193.     {$ENDC}
  194. FUNCTION MIDIGetClients: MIDIIDListHandle;
  195.     {$IFC NOT GENERATINGCFM}
  196.     INLINE $203C, $000C, 4, $A800;
  197.     {$ENDC}
  198. PROCEDURE MIDIGetClientName(clientID: OSType; VAR name: Str255);
  199.     {$IFC NOT GENERATINGCFM}
  200.     INLINE $203C, $0010, 4, $A800;
  201.     {$ENDC}
  202. PROCEDURE MIDISetClientName(clientID: OSType; name: ConstStr255Param);
  203.     {$IFC NOT GENERATINGCFM}
  204.     INLINE $203C, $0014, 4, $A800;
  205.     {$ENDC}
  206. FUNCTION MIDIGetPorts(clientID: OSType): MIDIIDListHandle;
  207.     {$IFC NOT GENERATINGCFM}
  208.     INLINE $203C, $0018, 4, $A800;
  209.     {$ENDC}
  210. FUNCTION MIDIAddPort(clientID: OSType; BufSize: INTEGER; VAR refnum: INTEGER; init: MIDIPortParamsPtr): OSErr;
  211.     {$IFC NOT GENERATINGCFM}
  212.     INLINE $203C, $001C, 4, $A800;
  213.     {$ENDC}
  214. FUNCTION MIDIGetPortInfo(clientID: OSType; portID: OSType): MIDIPortInfoHandle;
  215.     {$IFC NOT GENERATINGCFM}
  216.     INLINE $203C, $0020, 4, $A800;
  217.     {$ENDC}
  218. FUNCTION MIDIConnectData(srcClID: OSType; srcPortID: OSType; dstClID: OSType; dstPortID: OSType): OSErr;
  219.     {$IFC NOT GENERATINGCFM}
  220.     INLINE $203C, $0024, 4, $A800;
  221.     {$ENDC}
  222. FUNCTION MIDIUnConnectData(srcClID: OSType; srcPortID: OSType; dstClID: OSType; dstPortID: OSType): OSErr;
  223.     {$IFC NOT GENERATINGCFM}
  224.     INLINE $203C, $0028, 4, $A800;
  225.     {$ENDC}
  226. FUNCTION MIDIConnectTime(srcClID: OSType; srcPortID: OSType; dstClID: OSType; dstPortID: OSType): OSErr;
  227.     {$IFC NOT GENERATINGCFM}
  228.     INLINE $203C, $002C, 4, $A800;
  229.     {$ENDC}
  230. FUNCTION MIDIUnConnectTime(srcClID: OSType; srcPortID: OSType; dstClID: OSType; dstPortID: OSType): OSErr;
  231.     {$IFC NOT GENERATINGCFM}
  232.     INLINE $203C, $0030, 4, $A800;
  233.     {$ENDC}
  234. PROCEDURE MIDIFlush(refnum: INTEGER);
  235.     {$IFC NOT GENERATINGCFM}
  236.     INLINE $203C, $0034, 4, $A800;
  237.     {$ENDC}
  238. FUNCTION MIDIGetReadHook(refnum: INTEGER): ProcPtr;
  239.     {$IFC NOT GENERATINGCFM}
  240.     INLINE $203C, $0038, 4, $A800;
  241.     {$ENDC}
  242. PROCEDURE MIDISetReadHook(refnum: INTEGER; hook: ProcPtr);
  243.     {$IFC NOT GENERATINGCFM}
  244.     INLINE $203C, $003C, 4, $A800;
  245.     {$ENDC}
  246. PROCEDURE MIDIGetPortName(clientID: OSType; portID: OSType; VAR name: Str255);
  247.     {$IFC NOT GENERATINGCFM}
  248.     INLINE $203C, $0040, 4, $A800;
  249.     {$ENDC}
  250. PROCEDURE MIDISetPortName(clientID: OSType; portID: OSType; name: ConstStr255Param);
  251.     {$IFC NOT GENERATINGCFM}
  252.     INLINE $203C, $0044, 4, $A800;
  253.     {$ENDC}
  254. PROCEDURE MIDIWakeUp(refnum: INTEGER; time: LONGINT; period: LONGINT; timeProc: MIDITimeUPP);
  255.     {$IFC NOT GENERATINGCFM}
  256.     INLINE $203C, $0048, 4, $A800;
  257.     {$ENDC}
  258. PROCEDURE MIDIRemovePort(refnum: INTEGER);
  259.     {$IFC NOT GENERATINGCFM}
  260.     INLINE $203C, $004C, 4, $A800;
  261.     {$ENDC}
  262. FUNCTION MIDIGetSync(refnum: INTEGER): INTEGER;
  263.     {$IFC NOT GENERATINGCFM}
  264.     INLINE $203C, $0050, 4, $A800;
  265.     {$ENDC}
  266. PROCEDURE MIDISetSync(refnum: INTEGER; sync: INTEGER);
  267.     {$IFC NOT GENERATINGCFM}
  268.     INLINE $203C, $0054, 4, $A800;
  269.     {$ENDC}
  270. FUNCTION MIDIGetCurTime(refnum: INTEGER): LONGINT;
  271.     {$IFC NOT GENERATINGCFM}
  272.     INLINE $203C, $0058, 4, $A800;
  273.     {$ENDC}
  274. PROCEDURE MIDISetCurTime(refnum: INTEGER; time: LONGINT);
  275.     {$IFC NOT GENERATINGCFM}
  276.     INLINE $203C, $005C, 4, $A800;
  277.     {$ENDC}
  278. PROCEDURE MIDIStartTime(refnum: INTEGER);
  279.     {$IFC NOT GENERATINGCFM}
  280.     INLINE $203C, $0060, 4, $A800;
  281.     {$ENDC}
  282. PROCEDURE MIDIStopTime(refnum: INTEGER);
  283.     {$IFC NOT GENERATINGCFM}
  284.     INLINE $203C, $0064, 4, $A800;
  285.     {$ENDC}
  286. PROCEDURE MIDIPoll(refnum: INTEGER; offsetTime: LONGINT);
  287.     {$IFC NOT GENERATINGCFM}
  288.     INLINE $203C, $0068, 4, $A800;
  289.     {$ENDC}
  290. FUNCTION MIDIWritePacket(refnum: INTEGER; packet: MIDIPacketPtr): OSErr;
  291.     {$IFC NOT GENERATINGCFM}
  292.     INLINE $203C, $006C, 4, $A800;
  293.     {$ENDC}
  294. FUNCTION MIDIWorldChanged(clientID: OSType): BOOLEAN;
  295.     {$IFC NOT GENERATINGCFM}
  296.     INLINE $203C, $0070, 4, $A800;
  297.     {$ENDC}
  298. FUNCTION MIDIGetOffsetTime(refnum: INTEGER): LONGINT;
  299.     {$IFC NOT GENERATINGCFM}
  300.     INLINE $203C, $0074, 4, $A800;
  301.     {$ENDC}
  302. PROCEDURE MIDISetOffsetTime(refnum: INTEGER; offsetTime: LONGINT);
  303.     {$IFC NOT GENERATINGCFM}
  304.     INLINE $203C, $0078, 4, $A800;
  305.     {$ENDC}
  306. FUNCTION MIDIConvertTime(srcFormat: INTEGER; dstFormat: INTEGER; time: LONGINT): LONGINT;
  307.     {$IFC NOT GENERATINGCFM}
  308.     INLINE $203C, $007C, 4, $A800;
  309.     {$ENDC}
  310. FUNCTION MIDIGetRefCon(refnum: INTEGER): LONGINT;
  311.     {$IFC NOT GENERATINGCFM}
  312.     INLINE $203C, $0080, 4, $A800;
  313.     {$ENDC}
  314. PROCEDURE MIDISetRefCon(refnum: INTEGER; refCon: LONGINT);
  315.     {$IFC NOT GENERATINGCFM}
  316.     INLINE $203C, $0084, 4, $A800;
  317.     {$ENDC}
  318. FUNCTION MIDIGetClRefCon(clientID: OSType): LONGINT;
  319.     {$IFC NOT GENERATINGCFM}
  320.     INLINE $203C, $0088, 4, $A800;
  321.     {$ENDC}
  322. PROCEDURE MIDISetClRefCon(clientID: OSType; refCon: LONGINT);
  323.     {$IFC NOT GENERATINGCFM}
  324.     INLINE $203C, $008C, 4, $A800;
  325.     {$ENDC}
  326. FUNCTION MIDIGetTCFormat(refnum: INTEGER): INTEGER;
  327.     {$IFC NOT GENERATINGCFM}
  328.     INLINE $203C, $0090, 4, $A800;
  329.     {$ENDC}
  330. PROCEDURE MIDISetTCFormat(refnum: INTEGER; format: INTEGER);
  331.     {$IFC NOT GENERATINGCFM}
  332.     INLINE $203C, $0094, 4, $A800;
  333.     {$ENDC}
  334. PROCEDURE MIDISetRunRate(refnum: INTEGER; rate: INTEGER; time: LONGINT);
  335.     {$IFC NOT GENERATINGCFM}
  336.     INLINE $203C, $0098, 4, $A800;
  337.     {$ENDC}
  338. FUNCTION MIDIGetClientIcon(clientID: OSType): Handle;
  339.     {$IFC NOT GENERATINGCFM}
  340.     INLINE $203C, $009C, 4, $A800;
  341.     {$ENDC}
  342. FUNCTION SndDispVersion(toolnum: INTEGER): LONGINT;
  343.     {$IFC NOT GENERATINGCFM}
  344.     INLINE $203C, $0000, $0000, $A800;
  345.     {$ENDC}
  346. CONST
  347.     uppMIDIReadHookProcInfo = $000003E0; { FUNCTION (4 byte param, 4 byte param): 2 byte result; }
  348.     uppMIDITimeProcInfo = $000003C0; { PROCEDURE (4 byte param, 4 byte param); }
  349.  
  350. FUNCTION NewMIDIReadHookProc(userRoutine: MIDIReadHookProcPtr): MIDIReadHookUPP;
  351.     {$IFC NOT GENERATINGCFM }
  352.     INLINE $2E9F;
  353.     {$ENDC}
  354.  
  355. FUNCTION NewMIDITimeProc(userRoutine: MIDITimeProcPtr): MIDITimeUPP;
  356.     {$IFC NOT GENERATINGCFM }
  357.     INLINE $2E9F;
  358.     {$ENDC}
  359.  
  360. FUNCTION CallMIDIReadHookProc(myPacket: MIDIPacketPtr; myRefCon: LONGINT; userRoutine: MIDIReadHookUPP): INTEGER;
  361.     {$IFC NOT GENERATINGCFM}
  362.     INLINE $205F, $4E90;
  363.     {$ENDC}
  364.  
  365. PROCEDURE CallMIDITimeProc(curTime: LONGINT; myRefCon: LONGINT; userRoutine: MIDITimeUPP);
  366.     {$IFC NOT GENERATINGCFM}
  367.     INLINE $205F, $4E90;
  368.     {$ENDC}
  369.  
  370. {$ALIGN RESET}
  371. {$POP}
  372.  
  373. {$SETC UsingIncludes := MIDIIncludes}
  374.  
  375. {$ENDC} {__MIDI__}
  376.  
  377. {$IFC NOT UsingIncludes}
  378.  END.
  379. {$ENDC}
  380.